"""
URL configuration for FreshMart project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from rest_framework_simplejwt.views import TokenRefreshView, TokenVerifyView,TokenObtainPairView
from account.views import RegisterView, AlipayPaymentView, AlipayNotifyView, BindorUnbindView, LoginView, UserView, \
    LogoutView, AddressView, VerifCodeView, AlipayReturnView

router = DefaultRouter()
router.register(r'register', RegisterView, basename='register')
router.register(r'users', UserView, basename='users')
router.register(r'address', AddressView, basename='address')
urlpatterns = [
    path('admin/', admin.site.urls),
    path('token/refresh', TokenRefreshView.as_view(), name='token_refresh'),  # token刷新
    path('', include(router.urls)),
    path('logout/', LogoutView.as_view()),
    path('avatar/upload/', UserView.as_view({'post': 'upload_avatar'})),
    path('getatatar/', UserView.as_view({'get': 'get_avatar'})),
    path('token/verify/', TokenVerifyView.as_view(), name='token_verify'),  # token校验
    path('<int:pk>/default/', AddressView.as_view({'put': 'set_default_addr'})),
    path('<int:pk>/name/', UserView.as_view({'put': 'update_name'})),
    # 更改邮箱地址
    path('<int:pk>/email/', UserView.as_view({'patch': 'update_email'})),
    path('send/', VerifCodeView.as_view()),
    path('bind/', BindorUnbindView.as_view({'post': 'bind_mobile'})),
    path('unbind/', BindorUnbindView.as_view({'post': 'unbind_mobile'})),
    path('alipay/payment/', AlipayPaymentView.as_view(), name='alipay_payment'),
    path('alipay/return/', AlipayReturnView.as_view(), name='alipay_return'),
    path('alipay/notify/', AlipayNotifyView.as_view(), name='alipay_notify'),
]
